<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="/WEB-INF/tld/tags.tld"  prefix="t" %>
<html>
<head>
    <link rel="stylesheet" type="text/css" href="style/main.css">
    <title>Admissions. Catalog admissions</title>
</head>
<body>
<table class="tableBody">
    <tr>
        <td colspan="3">
            <t:header/>
        </td>
    </tr>
    <tr style="vertical-align: top">
        <td>
            <t:menu roleUser="${sessionScope.userRole}"/></td>
        <td style="background: #2c6932; width: 2px"/>
        <td style="width: 900px">
            <form name="admissionForm" action="controller" method="post">
                <table class="tableView">
                    <tr class="tableHeaderRow">
                        <td>№</td>
                        <td>Specialty</td>
                        <td>Group</td>
                        <td>Language</td>
                        <td>Teaching form</td>
                        <td>Teaching plan</td>
                        <td>Plan count</td>
                        <td>Fact count</td>
                        <td>Deviation</td>
                        <td>Delete</td>
                    </tr>
                    <c:set var="number" value="1"/>
                    <c:forEach var="admission" items="${requestScope.admissions}">
                        <tr>
                            <td>${number}<input type="hidden" name="idAdmission" value="${admission.id}"></td>
                            <td>
                                <c:set var="selectSpecialty" value="${admission.specialty}"/>
                                <select name="changeSpecialty">
                                    <c:forEach var="specialtyI" items="${requestScope.specialties}">
                                        <option value="${specialtyI.code}" ${specialtyI.name == selectSpecialty.name ? 'selected' : ''}>${specialtyI.code}-${specialtyI.name}</option>
                                    </c:forEach>
                                </select>
                            </td>
                            <td><input type="text" value="${admission.group}" name="changeGroup"
                                       style="width: 50px">
                            </td>
                            <td><select name="changeLanguage">
                                <c:forEach var="lang" items="${requestScope.languages}">
                                    <option value="${lang}" ${admission.language == lang ? 'selected' : ''}>${lang}</option>
                                </c:forEach>
                            </select></td>
                            <td>
                                <c:set var="selectTeachingForm" value="${admission.teachingForm}"/>
                                <select name="changeTeachingForm">
                                    <c:forEach var="forms" items="${requestScope.teachingForms}">
                                        <option value="${forms.form}" ${forms.form == selectTeachingForm.form ? 'selected' : ''}>${forms.form}</option>
                                    </c:forEach>
                                </select>
                            </td>
                            <td>
                                <c:set var="selectTeachingPlan" value="${admission.teachingPlan}"/>
                                <select name="changeTeachingPlan">
                                    <c:forEach var="plans" items="${requestScope.teachingPlans}">
                                        <option value="${plans.planName}" ${plans.planName == selectTeachingPlan.planName ? 'selected' : ''}>${plans.planName}</option>
                                    </c:forEach>
                                </select>
                            </td>
                            <td>
                                <input type="text" value="${admission.planCount}" name="changePlanCount"
                                       style="width: 50px">
                            </td>
                            <td>${admission.factCount}</td>
                            <td>${admission.deviation}</td>
                            <td><input type="checkbox" value="${admission.id}" name="checkbox"/></td>
                        </tr>
                        <c:set var="number" value="${number+1}"/>
                    </c:forEach>
                    <tr>
                        <td/>
                        <td>
                            <select name="newSpecialty">
                                <option>-</option>
                                <c:forEach var="specialty" items="${requestScope.specialties}">
                                    <option>${specialty.code}-${specialty.name}</option>
                                </c:forEach>
                            </select>
                        </td>
                        <td><input type="text" name="newGroup"
                                   style="width: 50px">
                        </td>
                        <td><select name="newLanguage">
                            <c:forEach var="lang" items="${requestScope.languages}">
                                <option>${lang}</option>
                            </c:forEach>
                        </select></td>
                        <td>
                            <select name="newTeachingForm">
                                <c:forEach var="forms" items="${requestScope.teachingForms}">
                                    <option value="${forms.form}" ${forms.form == selectTeachingForm ? 'selected' : ''}>${forms.form}</option>
                                </c:forEach>
                            </select>
                        </td>
                        <td>
                            <select name="newTeachingPlan">
                                <c:forEach var="plans" items="${requestScope.teachingPlans}">
                                    <option value="${plans.planName}" ${plans.planName == selectTeachingPlan ? 'selected' : ''}>${plans.planName}</option>
                                </c:forEach>
                            </select>
                        </td>
                        <td>
                            <input type="text" name="newPlanCount" style="width: 50px">
                        </td>
                        <td/>
                        <td/>
                        <td/>
                    </tr>
                    <tr>
                        <td colspan="8" style="text-align: left">
                            <input type="hidden" name="action" value="saveAdmission">
                            <input type="submit" value="Save" name="submit" class="commandButton" >
                        </td>
                    </tr>
                </table>
            </form>
        </td>
    </tr>
    <tr>
        <td colspan="3">
            <t:footer/>
        </td>
    </tr>
</table>
</body>
</html>